package com.njitzx.controller;


import com.njitzx.entity.po.Express;
import com.njitzx.service.ExpressService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.njitzx.entity.vo.Result;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import lombok.RequiredArgsConstructor;



import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 快递表 前端控制器
 * </p>
 *
 * @author 周鑫
 * @since 2024-08-20
 */
@Api(tags = "快递表接口")
@RestController
@RequestMapping("/express")
@RequiredArgsConstructor
public class ExpressController {

    private final ExpressService expressService;

    @ApiOperation("快递表分页查询")
    @GetMapping("/list")
    public Result findPage(@ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
                               @ApiParam("页大小") @RequestParam(defaultValue = "5") Integer pageSize,
                               @ApiParam("查询条件") Express express){
        PageInfo<Express> pageInfo = expressService.findPage(pageNum,pageSize,express);
        return Result.success(pageInfo);
    }

    @ApiOperation("根据主键查询快递表")
    @GetMapping("/{expressId}")
    public Result findById(@PathVariable Serializable expressId){
        return Result.success(expressService.findById(expressId));
    }

    @ApiOperation("新增快递表")
    @PostMapping
    public Result add(@RequestBody Express express){
        expressService.add(express);
        return Result.success();
    }

    @ApiOperation("修改快递表")
    @PutMapping
    public Result modify(@RequestBody Express express){
        expressService.modify(express);
        return Result.success();
    }

    @ApiOperation("根据主键删除快递表")
    @DeleteMapping("/{expressId}")
    public Result removeById(@PathVariable Serializable expressId){
        expressService.removeById(expressId);
        return Result.success();
    }

}
